//Handin 5, due 10/10 2011
//Author Johan Sivertsen



package handin_5;

import java.util.Scanner;

public class MagicSquareRunner {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
			//Initializing variables
			Scanner in = new Scanner(System.in);			
			int n = 3;
			int input;
			
			
			//Creating new square candidate of n length.
			MagicSquare ms = new MagicSquare(n);
			
			//User instructions to cosole
			System.out.println("Please enter the numbers 1.."+n*n+" in the magic order");
			
			//While loop running until the correct number of valid inputs have been reached.
			while(!ms.correctNumberOfElements())
			{
			System.out.println("Still to be used: "+ms.unusedNumbers());
			input = in.nextInt();
			if(ms.unusedNumbers().contains((Integer) input))
					{
					ms.addElement(input)	;
					}
			else
			{
				System.out.println("That is not a valid input, please input an element from the list.");
			}

			}
			
			//Print the square to the console.
			System.out.println("Your sqare candidate:");	
			ms.printSquare();
			
			//Check whether this is a MagicSquare. Returns a quote from Arrested Development.
			if(ms.isMagic())
			{
				
				System.out.println("What a nice little trick Gob\nIt's called an illusion Michael!");	
			}
			else 
			{
				System.out.println("Okay, not so magic!\nStill, where did the lighter fluid come from?");	
			}
			
		

	}

}
